<?php
/**
 * 后台用户信息服务
 * User: EDZ
 * Date: 2020/12/19
 * TIME: 15:38
 */
namespace app\admin_product_library\admin_user_module\service;

use app\admin_product_libaray\admin_user_module\model\UserInfoModel;
use think\facade\Session;

class UserInfoService {

    /**
     * 设置用户信息
     *
     * @param $uid
     * @return bool
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function setUserInfo($uid){
        $userInfo = UserInfoModel::getUserInfo($uid);
        Session::set('userInfo',$userInfo);
        return true;
    }

    /**
     * @param $username
     * @param $password
     * @return array|\PDOStatement|string|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function getUserInfo($username,$password){
        $userInfo = UserInfoModel::getLoginUserInfo($username,$password);
        return $userInfo;
    }
}